
%% OBSERVATION POSITIONS
udata.obs = [15	50;
            15	63;
            %15	73.5;
            115	37.5;
            %115	43.5;
            115	58;
            115	65;
            %115	71.5;
            ];  

%% COORDINATES CORRECTION
obs_xy=udata.obs;
N_obs=size(udata.obs,1);
N_frac_seg=size(XY1,1);

for i = 1:N_obs
    xy_try=ones(N_frac_seg,1)*udata.obs(i,:);
    dist=xy_try-XY1(:,1:2);
    dist_=sqrt(dist(:,1).^2+dist(:,2).^2);
    obs_xy(i,:)=ceil(XY1(dist_==min(dist_),1:2));
end
    
%% INITIAL CONDITIONS--------------------------------------------------------------------------------%   
udata.T0f  = 100*ones(udata.Nf_f,1);               % Initial fracture temperature [oC]
udata.p0f  = zeros(udata.Nf_f,1)+30*1e6;                  % Initial fracture pressure [Pa]

%% SOURCE TERMS ------------------------------------------------------------------------------------%
Q       = zeros(udata.Nf);                         % Source term [m2/s]; inflow positive
QT      = zeros(udata.Nf)+100;                         % Inflow temperature [oC] 


Q(obs_xy(1,1),obs_xy(1,2))  = 0.0002;
Q(obs_xy(2,1),obs_xy(2,2))  = 0.0002;
%Q(obs_xy(3,1),obs_xy(3,2))  = 0.0002;
QT(obs_xy (1,1),obs_xy(1,2))=50;
QT(obs_xy (2,1),obs_xy(2,2))=50;
%QT(obs_xy (3,1),obs_xy(3,2))=50;

%Q(obs_xy(4,1),obs_xy(4,2))  = -0.0001;
% Q(obs_xy(5,1),obs_xy(5,2))  = -0.0001;
% Q(obs_xy(6,1),obs_xy(6,2))  = -0.0001;
% Q(obs_xy(7,1),obs_xy(7,2))  = -0.0001;
% Q(obs_xy(8,1),obs_xy(8,2))  = -0.0001;

Q(obs_xy(3,1),obs_xy(3,2))  = -0.0001;
Q(obs_xy(4,1),obs_xy(4,2))  = -0.0001;
Q(obs_xy(5,1),obs_xy(5,2))  = -0.0001;



 %% Fracture aperture
udata.b0      = apert.*ones(udata.Nf_f,1);  % Fracture aperture field [m]

 %% PERMEABILITY ------------------------------------------------------------------------------------%
udata.K_f     = udata.b0.^2/12;         % Fracture permeability field [m2]

%% Porosity ----------------------------------------------------------------------------------------%
udata.phi_f   = ones(udata.Nf_f,1)*0.3;            % Fracture porosity field [-]

%% Fluid density ------------------------------------------------------------------------%
if(udata.const_density)
    udata.density_lf = 1000*ones(udata.Nf_f,1);    % Density of the fluid [kg/m3]
end

%% Fluid viscosity ------------------------------------------------------------------------%
if(udata.const_viscosity)
    udata.viscosity_f = 1e-3*ones(udata.Nf_f,1);   % Viscosity of the fluid [Pa*s]
end

%% ROCK DENSITY ------------------------------------------------------------------------%
udata.density_sf = 2700*ones(udata.Nf_f,1);        % Density of the rock [kg/m3]

%% MECHANIC PROPERTIES
udata.frac_az  = 90*ones(size(udata.frac_angle));  % Fracture dip [o]
udata.frac_dip = min(abs(udata.frac_angle),180-abs(udata.frac_angle)); % Fracture azimuth (from N) [o]
udata.friction_coeff = 0.6*ones(udata.Nf_f,1);     % Friction coefficient (shear failure) [-]
udata.sigma_1 = 20e9*ones(udata.Nf_f,1);           % Maximum principal stress (S1) [Pa]
udata.sigma_2 = 14e9*ones(udata.Nf_f,1);           % Intermeadiate principal stress (S2) [Pa]
udata.sigma_3 = 12e9*ones(udata.Nf_f,1);           % Minimum principal stress (S3) [Pa]